{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Mapping Geographic Subjects using the HathiTrust Extracted Features Dataset"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In a [recent post](https://github.com/diyclassics/mapping-experiments/blob/master/marc-ner-map.ipynb), I explained how I was running NER over MARC records in order to extract and map location data for the [ISAW Library](http://isaw.nyu.edu/library) Again, not determining \"What a book is about?\" but \"Where is it about?\" The notebook approaches the same problem from a different perspective. Here I use data from the HathiTrust Extracted Features Dataset to recreate the same geolocated subject map as I produced in the previous post. The workflow is as follows:\n",
    "\n",
    "- Retrieve a book-level dataset from the [HathiTrust Extracted Features Dataset](https://wiki.htrc.illinois.edu/display/COM/Extracted+Features+Dataset)\n",
    "- \"Recreate\" the book's text using token-frequency data (i.e. tokenPosCount)\n",
    "- Run the text through a named entity recognition tagger ([Stanford NER Tagger](https://nlp.stanford.edu/software/CRF-NER.html))\n",
    "- Separate out 'location' NER data\n",
    "- Query the [Geonames](http://www.geonames.org/) API for geographic coordinates for all locations\n",
    "- Map the coordinates using [Folium](http://python-visualization.github.io/folium/)\n",
    "\n",
    "As with the previous notebook, I use the American School of Classical Studies at Athens's 1947 [\"Ancient Corinth: A guide to the excavations\"](http://www.worldcat.org/title/ancient-corinth-a-guide-to-the-excavations/oclc/10220993). (This is the fourth edition, revised by O. Broneer.) Encouragingly, the top three \"locations\" returned with this worklow correspond with those from the previous experiment. One additional benefit, as shown here through marker size, is a better sense of the \"weight\" of each location. Corinth is tagged 48 times as a location in the results, Athens 14 times, and Greece 12 times. We learn from these results not just that Corinth is an important subject of this book (obvious enough), but that it is *the* most important subject by a factor of around four.\n",
    "\n",
    "There is one clear problem that arises here because of the [\"non-consumptive\"](https://www.hathitrust.org/htrc_ncup) nature of the HTEF data. NER results are limited to single-word expressions. Accordingly, one direction of my research on geographic subject mapping is on precisely this—trying to extract multi-word locations from randomized page data. [PJB 3.20.18]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Imports\n",
    "\n",
    "import os\n",
    "\n",
    "import random\n",
    "\n",
    "from collections import Counter, defaultdict\n",
    "import random\n",
    "\n",
    "from nltk.tag import StanfordNERTagger\n",
    "from nltk.tokenize import word_tokenize\n",
    "from nltk import pos_tag\n",
    "from nltk.chunk import conlltags2tree\n",
    "from nltk.tree import Tree\n",
    "\n",
    "import pandas as pd\n",
    "from htrc_features import FeatureReader\n",
    "\n",
    "import geocoder\n",
    "\n",
    "import folium\n",
    "\n",
    "from pprint import pprint\n",
    "from tqdm import tqdm"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Set environment variable\n",
    "# Geonames requires a username to access the API but we do not want to expose personal info in code\n",
    "#\n",
    "# Run this locally by adding USERNAME to environment variables, e.g. to .env, as follows:\n",
    "# > export USERNAME=<insert username here>\n",
    "\n",
    "USERNAME = os.getenv('USERNAME')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Setup Stanford NER Tagger\n",
    "# Ignore deprecation warning for now; we'll deal with it when the time comes!\n",
    "\n",
    "st = StanfordNERTagger('/usr/local/share/stanford-ner/classifiers/english.all.3class.distsim.crf.ser.gz', \n",
    "                       '/usr/local/share/stanford-ner/stanford-ner.jar',\n",
    "                       encoding='utf-8')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Functions for putting together with inside-outside-beginning (IOB) logic\n",
    "# Cf. https://stackoverflow.com/a/30666949\n",
    "#\n",
    "# For more information on IOB tagging, see https://en.wikipedia.org/wiki/Inside–outside–beginning_(tagging)\n",
    "\n",
    "def stanfordNE2BIO(tagged_sent):\n",
    "    bio_tagged_sent = []\n",
    "    prev_tag = \"O\"\n",
    "    for token, tag in tagged_sent:\n",
    "        if tag == \"O\": #O\n",
    "            bio_tagged_sent.append((token, tag))\n",
    "            prev_tag = tag\n",
    "            continue\n",
    "        if tag != \"O\" and prev_tag == \"O\": # Begin NE\n",
    "            bio_tagged_sent.append((token, \"B-\"+tag))\n",
    "            prev_tag = tag\n",
    "        elif prev_tag != \"O\" and prev_tag == tag: # Inside NE\n",
    "            bio_tagged_sent.append((token, \"I-\"+tag))\n",
    "            prev_tag = tag\n",
    "        elif prev_tag != \"O\" and prev_tag != tag: # Adjacent NE\n",
    "            bio_tagged_sent.append((token, \"B-\"+tag))\n",
    "            prev_tag = tag\n",
    "\n",
    "    return bio_tagged_sent\n",
    "\n",
    "\n",
    "def stanfordNE2tree(ne_tagged_sent):\n",
    "    bio_tagged_sent = stanfordNE2BIO(ne_tagged_sent)\n",
    "    sent_tokens, sent_ne_tags = zip(*bio_tagged_sent)\n",
    "    sent_pos_tags = [pos for token, pos in pos_tag(sent_tokens)]\n",
    "\n",
    "    sent_conlltags = [(token, pos, ne) for token, pos, ne in zip(sent_tokens, sent_pos_tags, sent_ne_tags)]\n",
    "    ne_tree = conlltags2tree(sent_conlltags)\n",
    "    return ne_tree"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Get HTEF Data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Sample HathiTrust ID\n",
    "# This is the HTID for... \n",
    "# \"Ancient Corinth: A guide to the excavations,\" O. Broneer, R. Carpenter, and C. H. Morgan\n",
    "\n",
    "htid = \"wu.89079728994\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/Users/pbartleby/.local/share/virtualenvs/mapping-experiments-GK9mgOWS/lib/python3.6/site-packages/htrc_features/feature_reader.py:603: FutureWarning: sortlevel is deprecated, use sort_index(level= ...)\n",
      "  df.sortlevel(inplace=True)\n"
     ]
    }
   ],
   "source": [
    "# Get HTEF data for this ID; specifically tokenlist\n",
    "\n",
    "fr = FeatureReader(ids=[htid])\n",
    "\n",
    "for vol in fr:\n",
    "    tokens = vol.tokenlist()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>page</th>\n",
       "      <th>section</th>\n",
       "      <th>token</th>\n",
       "      <th>pos</th>\n",
       "      <th>count</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2</td>\n",
       "      <td>body</td>\n",
       "      <td>Library</td>\n",
       "      <td>NNP</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>body</td>\n",
       "      <td>The</td>\n",
       "      <td>DT</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2</td>\n",
       "      <td>body</td>\n",
       "      <td>University</td>\n",
       "      <td>NNP</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2</td>\n",
       "      <td>body</td>\n",
       "      <td>Wisconsin</td>\n",
       "      <td>NNP</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2</td>\n",
       "      <td>body</td>\n",
       "      <td>of</td>\n",
       "      <td>IN</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>2</td>\n",
       "      <td>body</td>\n",
       "      <td>the</td>\n",
       "      <td>DT</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>7</td>\n",
       "      <td>body</td>\n",
       "      <td>!</td>\n",
       "      <td>.</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>7</td>\n",
       "      <td>body</td>\n",
       "      <td>#</td>\n",
       "      <td>#</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>7</td>\n",
       "      <td>body</td>\n",
       "      <td>*</td>\n",
       "      <td>,</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>7</td>\n",
       "      <td>body</td>\n",
       "      <td>-</td>\n",
       "      <td>:</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   page section       token  pos  count\n",
       "0     2    body     Library  NNP      1\n",
       "1     2    body         The   DT      1\n",
       "2     2    body  University  NNP      1\n",
       "3     2    body   Wisconsin  NNP      1\n",
       "4     2    body          of   IN      2\n",
       "5     2    body         the   DT      1\n",
       "6     7    body           !    .      1\n",
       "7     7    body           #    #      1\n",
       "8     7    body           *    ,      1\n",
       "9     7    body           -    :      1"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Create pandas dataframe with relevant data\n",
    "\n",
    "temp = tokens.index.values.tolist()\n",
    "counts = pd.DataFrame.from_records(temp, columns=['page', 'section', 'token', 'pos'])\n",
    "counts['count'] = tokens['count'].tolist()\n",
    "counts[:10]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Reconstruct text using tokens and counts\n",
    "\n",
    "text_data = list(zip(counts['token'].tolist(), counts['count'].tolist()))\n",
    "\n",
    "# Loop through and multiply words by counts\n",
    "\n",
    "text_list = []\n",
    "\n",
    "for w, c in text_data:\n",
    "    for i in range(0, c):\n",
    "        text_list.append(w)\n",
    "\n",
    "random.shuffle(text_list) # Necessary?\n",
    "text_reconstruction = \" \".join(text_list)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Named Entity Extraction on \"Reconstructed\" Book"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['West', 'Greece', 'Greece', 'Peribolos', 'Parnassos', 'Athens', 'Meritt', 'Hesperia', 'Bunaea', 'Spring Canada', 'Hera', 'Corinth', 'Lerna', 'Corinth', 'Aigosthena', 'Corinth', 'States', 'Ephesian', 'Peloponnese', 'Erotes', 'Corinth', 'Corinth', 'Lake', 'North', 'East', 'Hera', 'Greece', 'Greece', 'Peirene', 'Roman Corinth', 'Corinth', 'Agora', 'Greece', 'Stoa', 'Corinth', 'Maryland', 'Roman', 'Corinth', 'Corinth', 'Akraia', 'Corinthia', 'V* The Of The East', 'North', 'Corinth', 'Corinth', 'Corinth', 'Agora Heraeum', 'West', 'Corinth Briareos', 'Hera', 'Greece', 'Hera', 'Holland', 'Sikyon', 'South Corinth', 'Corinth', 'Corinth', 'Baltimore', 'Odeion', 'Corinth', 'Athens', 'Rome', 'Corinth', 'West', 'Lechaion Theater', 'Corinth', 'Corinth', 'Corinth', 'Peribolos', 'Corinthian Holland', 'Lechaeum', 'Corinth', 'Square', 'Greece', 'Canada', 'Corinth', 'Bellerephontes', 'Athens', 'Greece', 'America', 'Peirene', 'Athens', 'Peirene', 'Corinth', 'Athens', 'Corinth', 'Agora', 'Propylaea', 'Lerna', 'Corinth', 'Penteskouphia', 'Jersey', 'Diogenes', 'Greece', 'Gulf', 'Athens', 'Sicily', 'Venice', 'South East', 'Middle', 'Glauke', 'Hesperia', 'Gulf', 'Peloponnese', 'Corinth', 'Corinth', 'Athens', 'Kypselos', 'Corinth', 'Greece', 'Athens', 'Corinth', 'Corinth', 'Greek South', 'Argolid', 'Corinth', 'Lerna', 'Athens', 'Medea', 'Asia', 'Southeast', 'Lechaion Lais', 'Glauke', 'Thessaly', 'Athens', 'Gulf', 'Corinth', 'London', 'Pompeii', 'Athens', 'Kraneion', 'Hesperia', 'Propylaea', 'Villa Lechaion', 'Corfu', 'South', 'Corinth', 'South', 'Corinth', 'Corinth', 'Laconia', 'Corinth', 'Corinth', 'Corinth', 'Asklepieion', 'Mycenae', 'Athens', 'Considering Jersey', 'Hera', 'Corinth', 'Corinth', 'Corinth', 'Corinth', 'Medea', 'Parnassos', 'Hycara Facade', 'Greece', 'Scranton', 'Mycenae', 'Eutychia', 'Loutraki', 'Cambridge', 'Corinth', 'Epidaurus', 'Kiona', 'Greece', 'Meritt', 'Nemea', 'Medea Greece', 'Northwest', 'Rome', 'West', 'Gulf', 'Corinth', 'Athens', 'Corinth', 'Hera', 'Corinth', 'Road', 'Peirene', 'Corinth']\n"
     ]
    }
   ],
   "source": [
    "\n",
    "#page_words_extended = page_words+page_ner\n",
    "\n",
    "tokens = word_tokenize(text_reconstruction)\n",
    "tagged_tokens = st.tag(tokens)\n",
    "tagged_tokens = [item for item in tagged_tokens if item[0] != '']\n",
    "ne_tree = stanfordNE2tree(tagged_tokens)\n",
    "\n",
    "ne_in_sent = []\n",
    "for subtree in ne_tree:\n",
    "    if type(subtree) == Tree: # If subtree is a noun chunk, i.e. NE != \"O\"\n",
    "        ne_label = subtree.label()\n",
    "        ne_string = \" \".join([token for token, pos in subtree.leaves()])\n",
    "        ne_in_sent.append((ne_string, ne_label))\n",
    "\n",
    "\n",
    "    \n",
    "locations = [tag[0].title() for tag in ne_in_sent if tag[1] == 'LOCATION']\n",
    "\n",
    "print(locations)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[('Corinth', 46),\n",
      " ('Athens', 13),\n",
      " ('Greece', 12),\n",
      " ('Hera', 6),\n",
      " ('West', 4),\n",
      " ('Peirene', 4),\n",
      " ('Gulf', 4),\n",
      " ('Hesperia', 3),\n",
      " ('Lerna', 3),\n",
      " ('Peribolos', 2)]\n"
     ]
    }
   ],
   "source": [
    "most_common_locations = Counter(locations).most_common(10)\n",
    "pprint(most_common_locations)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Disambiguate placenames"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Organize some data for map info\n",
    "\n",
    "places_list = [name for name, _ in most_common_locations][:3] # Limit to top three\n",
    "most_common_locations = dict(most_common_locations) # Turn mcl into dictionary"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "# Retrieve json from geonames API (for fun this time using geocoder)\n",
    "\n",
    "geocoder_results = []\n",
    "\n",
    "for place in places_list:\n",
    "    results = geocoder.geonames(place, maxRows=5, key=USERNAME)\n",
    "    jsons = []\n",
    "    for result in results:\n",
    "        jsons.append(result.json)\n",
    "    geocoder_results.append(jsons)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Create a list of 'country' from the geonames json results\n",
    "\n",
    "countries = []\n",
    "\n",
    "for results in geocoder_results:\n",
    "    for item in results:\n",
    "        if 'country' in item.keys():\n",
    "            countries.append(item['country'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Greece\n"
     ]
    }
   ],
   "source": [
    "# Determine which country appears most often\n",
    "\n",
    "top_country = sorted(Counter(countries))[0]\n",
    "print(top_country)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['Corinth', 'Athens', 'Greece']\n",
      "[(37.94007, 22.9513), (37.97945, 23.71622), (39.0, 22.0)]\n"
     ]
    }
   ],
   "source": [
    "# Iterate over geocoder_results and keep the first lat/long that matches the top country\n",
    "\n",
    "coordinates = []\n",
    "\n",
    "for i, results in enumerate(geocoder_results):\n",
    "    for item in results:\n",
    "        if item['country'] == top_country:\n",
    "            coordinates.append((float(item['lat']), float(item['lng'])))\n",
    "            break # Only get the first item for now\n",
    "\n",
    "print(places_list)            \n",
    "print(coordinates)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Create map"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Map of relevant locations in Broneer et al.'s \"Ancient Corinth: A guide to the excavations,\" weighted by frequency.\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div style=\"width:100%;\"><div style=\"position:relative;width:100%;height:0;padding-bottom:60%;\"><iframe src=\"data:text/html;charset=utf-8;base64,PCFET0NUWVBFIGh0bWw+CjxoZWFkPiAgICAKICAgIDxtZXRhIGh0dHAtZXF1aXY9ImNvbnRlbnQtdHlwZSIgY29udGVudD0idGV4dC9odG1sOyBjaGFyc2V0PVVURi04IiAvPgogICAgPHNjcmlwdD5MX1BSRUZFUl9DQU5WQVMgPSBmYWxzZTsgTF9OT19UT1VDSCA9IGZhbHNlOyBMX0RJU0FCTEVfM0QgPSBmYWxzZTs8L3NjcmlwdD4KICAgIDxzY3JpcHQgc3JjPSJodHRwczovL2Nkbi5qc2RlbGl2ci5uZXQvbnBtL2xlYWZsZXRAMS4yLjAvZGlzdC9sZWFmbGV0LmpzIj48L3NjcmlwdD4KICAgIDxzY3JpcHQgc3JjPSJodHRwczovL2FqYXguZ29vZ2xlYXBpcy5jb20vYWpheC9saWJzL2pxd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0gTC5tYXAoCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAnbWFwX2ZiNjUxODBiNDA1YTQ3ZmVhZWU1ZjRkMzVlZGZiMWEzJywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHtjZW50ZXI6IFszNy45Nzk0NSwyMy43MTYyMl0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB6b29tOiA4LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWF4Qm91bmRzOiBib3VuZHMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsYXllcnM6IFtdLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd29ybGRDb3B5SnVtcDogZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjcnM6IEwuQ1JTLkVQU0czODU3CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAKICAgICAgICAKICAgIAogICAgICAgICAgICB2YXIgdGlsZV9sYXllcl9mMjM5YTljYTVjNTM0M2U1YTk2MmM2ZTM5NmJiY2IyZSA9IEwudGlsZUxheWVyKAogICAgICAgICAgICAgICAgJ2h0dHBzOi8vY2FydG9kYi1iYXNlbWFwcy17c30uZ2xvYmFsLnNzbC5mYXN0bHkubmV0L2xpZ2h0X2FsbC97en0ve3h9L3t5fS5wbmcnLAogICAgICAgICAgICAgICAgewogICJhdHRyaWJ1dGlvbiI6IG51bGwsCiAgImRldGVjdFJldGluYSI6IGZhbHNlLAogICJtYXhab29tIjogMTgsCiAgIm1pblpvb20iOiAxLAogICJub1dyYXAiOiBmYWxzZSwKICAic3ViZG9tYWlucyI6ICJhYmMiCn0KICAgICAgICAgICAgICAgICkuYWRkVG8obWFwX2ZiNjUxODBiNDA1YTQ3ZmVhZWU1ZjRkMzVlZGZiMWEzKTsKICAgICAgICAKICAgIAogICAgICAgICAgICB2YXIgY2lyY2xlX21hcmtlcl8zZWYxZWY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ICJsaW5lSm9pbiI6ICJyb3VuZCIsCiAgIm9wYWNpdHkiOiAxLjAsCiAgInJhZGl1cyI6IDMuMCwKICAic3Ryb2tlIjogdHJ1ZSwKICAid2VpZ2h0IjogMwp9CiAgICAgICAgICAgICAgICApLmFkZFRvKG1hcF9mYjY1MTgwYjQwNWE0N2ZlYWVlNWY0ZDM1ZWRmYjFhMyk7CiAgICAgICAgICAgIAogICAgCiAgICAgICAgICAgIHZhciBwb3B1cF9lOTlhNWYzZWFjN2I0MGE1YWNlYmJkNThlNjg0NmI3ZCA9IEwucG9wdXAoe21heFdpZHRoOiAnMzAwJ30pOwoKICAgICAgICAgICAgCiAgICAgICAgICAgICAgICB2YXIgaHRtbF9hMzhlMzYxYTJkZjk0MDlkYTliODFiYzc2NDRiOWM2NiA9ICQoJzxkaXYgaWQ9Imh0bWxfYTM4ZTM2MWEyZGY5NDA5ZGE5YjgxYmM3NjQ0YjljNjYiIHN0eWxlPSJ3aWR0aDogMTAwLjAlOyBoZWlnaHQ6IDEwMC4wJTsiPkdyZWVjZSAoMzkuMCwgMjIuMCkgYXBwZWFycyAxMiB0aW1lcyBpbiBib29rLjwvZGl2PicpWzBdOwogICAgICAgICAgICAgICAgcG9wdXBfZTk5YTVmM2VhYzdiNDBhNWFjZWJiZDU4ZTY4NDZiN2Quc2V0Q29udGVudChodG1sX2EzOGUzNjFhMmRmOTQwOWRhOWI4MWJjNzY0NGI5YzY2KTsKICAgICAgICAgICAgCgogICAgICAgICAgICBjaXJjbGVfbWFya2VyXzEyYTBjOTBjZmI5YzRhZTFiYTgyMmIyZWFjNzZiMjA3LmJpbmRQb3B1cChwb3B1cF9lOTlhNWYzZWFjN2I0MGE1YWNlYmJkNThlNjg0NmI3ZCk7CgogICAgICAgICAgICAKICAgICAgICAKPC9zY3JpcHQ+\" style=\"position:absolute;width:100%;height:100%;left:0;top:0;border:none !important;\" allowfullscreen webkitallowfullscreen mozallowfullscreen></iframe></div></div>"
      ],
      "text/plain": [
       "<folium.folium.Map at 0x10c287940>"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Set up Folium and populate with weighted coordinates\n",
    "\n",
    "basemap = folium.Map(location=[37.97945, 23.71622], zoom_start=8, tiles='cartodbpositron', width=960, height=512)\n",
    "\n",
    "for i, c in enumerate(coordinates):\n",
    "    folium.CircleMarker([c[0], c[1]], radius=most_common_locations[places_list[i]]*.25, color='#3186cc',\n",
    "                    fill=True, fill_opacity=0.5, fill_color='#3186cc', \n",
    "                    popup='{} ({}, {}) appears {} times in book.'.format(places_list[i], c[0], c[1], most_common_locations[places_list[i]])).add_to(basemap)\n",
    "\n",
    "print('Map of relevant locations in Broneer et al.\\'s \"Ancient Corinth: A guide to the excavations,\" weighted by frequency.')\n",
    "basemap"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Experiment: Two-word NER"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[\"'s\", ',', '-', '-beyond', '.', '1932', '79', ';', 'A', 'Almost', 'American', 'Apollo', 'Corinthian', 'E', 'Forum', 'From', 'Guide', 'Mounting', 'Museum', 'Parthenon', 'School', 'Specimens', 'Statuary', 'Temple', 'These', 'a', 'across', 'actual', 'adjoins', 'adorned', 'an', 'ancient', 'and', 'archaic', 'are', 'area', 'at', 'back', 'be', 'been', 'beside', 'both', 'busy', 'by', 'capitals', 'carved', 'city', 'closely', 'colonnades', 'colossal', 'columns', 'constructed', 'contemporary', 'contents', 'corner', 'courtyard', 'date', 'deity', 'derive', 'descend', 'described', 'desk', 'detailed', 'devoid', 'displayed', 'divinity', 'dominate', 'dwelling', 'early', 'earthquakes', 'echoing', 'entablature', 'entire', 'entrance', 'excavated', 'excavations', 'facade', 'female', 'few', 'finely', 'for', 'fragments', 'from', 'great', 'had', 'has', 'height', 'hill', 'him', 'houses', 'hurled', 'idle', 'image', 'imagination', 'imperial', 'important', 'imposing', 'in', 'indications', 'interior', 'is', 'it', 'its', 'look', 'marble', 'may', 'monuments', 'much', 'northeast', 'now', 'obtained', 'of', 'omphalos', 'on', 'once', 'only', 'or', 'partly', 'pedimental', 'people', 'platform', 'point', 'probably', 'published', 'recreate', 'remains', 'remnants', 'return', 'rivaled', 'rocky', 'roofs', 'scene', 'sculpture', 'seated', 'separately', 'shorter', 'sites', 'six', 'sole', 'south', 'splinters', 'square', 'standing', 'statue', 'style', 'suggests', 'surpassed', 'temple', 'than', 'that', 'the', 'their', 'they', 'this', 'though', 'throngs', 'tiled', 'to', 'toward', 'unfluted', 'upon', 'visit', 'we', 'were', 'where', 'which', 'while', 'whose', 'width', 'with']\n",
      "170\n"
     ]
    }
   ],
   "source": [
    "page = 87\n",
    "test = counts[counts['page'] == page]['token'].tolist()\n",
    "print(test)\n",
    "print(len(test))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 87,
   "metadata": {},
   "outputs": [],
   "source": [
    "from nltk.corpus import stopwords\n",
    "stops = set(stopwords.words('english'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 95,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['Greek Roman', 'Corinth Roman', 'Corinth Greek', 'Agora Roman', 'Roman South', 'Roman Stoa', 'Pausanias Roman', 'Corinthian Roman', 'Fig Roman', 'Corinth Pausanias', 'South Stoa', 'Acrocorinth Greek', 'Lechaion Road', 'Ionic Roman', 'Corinth Corinthian', 'Corinthian Greek', 'Fig Greek', 'Agora Corinth', 'Greece Greek', 'Agora Greek', 'Agora Pausanias', 'Acrocorinth Corinth', 'Christ Greek', 'Agora Corinthian', 'Agora Stoa']\n"
     ]
    }
   ],
   "source": [
    "pns_list = []\n",
    "for i in range(1, max(counts['page'])+1):\n",
    "    tokens = counts[counts['page'] == i]['token'].tolist()\n",
    "    tokens = [token for token in tokens if token.lower() not in stops and len(token) > 2]\n",
    "    pns = [token for token in tokens if token[0].isupper()]\n",
    "    combs = [f'{x} {y}' for x, y in combinations(pns, 2)]\n",
    "    pns_list.extend(combs)\n",
    "\n",
    "print([x for x, y in Counter(pns_list).most_common(25)])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 105,
   "metadata": {},
   "outputs": [],
   "source": [
    "geocoder_results = []\n",
    "\n",
    "for place in pns_list[:15]:\n",
    "    results = geocoder.geonames(place, maxRows=5, key=USERNAME)\n",
    "    jsons = []\n",
    "    for result in results:\n",
    "        jsons.append(result.json)\n",
    "    geocoder_results.append(jsons)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 106,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[[{'address': 'Østfold University College, The Library',\n",
       "   'class_description': 'spot, building, farm',\n",
       "   'code': 'LIBR',\n",
       "   'country': 'Norway',\n",
       "   'country_code': 'NO',\n",
       "   'description': 'library',\n",
       "   'feature_class': 'S',\n",
       "   'geonames_id': 7671067,\n",
       "   'lat': '59.12898',\n",
       "   'lng': '11.35567',\n",
       "   'ok': True,\n",
       "   'raw': {'adminCode1': '13',\n",
       "    'lng': '11.35567',\n",
       "    'geonameId': 7671067,\n",
       "    'toponymName': 'Østfold University College, The Library',\n",
       "    'countryId': '3144096',\n",
       "    'fcl': 'S',\n",
       "    'population': 0,\n",
       "    'countryCode': 'NO',\n",
       "    'name': 'Østfold University College, The Library',\n",
       "    'fclName': 'spot, building, farm',\n",
       "    'adminCodes1': {'ISO3166_2': '01'},\n",
       "    'countryName': 'Norway',\n",
       "    'fcodeName': 'library',\n",
       "    'adminName1': 'Østfold',\n",
       "    'lat': '59.12898',\n",
       "    'fcode': 'LIBR'},\n",
       "   'state': 'Østfold',\n",
       "   'state_code': '13',\n",
       "   'status': 'OK'},\n",
       "  {'address': 'University of Southern Mississippi McCain Library and Archives',\n",
       "   'class_description': 'spot, building, farm',\n",
       "   'code': 'LIBR',\n",
       "   'country': 'United States',\n",
       "   'country_code': 'US',\n",
       "   'description': 'library',\n",
       "   'feature_class': 'S',\n",
       "   'geonames_id': 4435276,\n",
       "   'lat': '31.32623',\n",
       "   'lng': '-89.33451',\n",
       "   'ok': True,\n",
       "   'raw': {'adminCode1': 'MS',\n",
       "    'lng': '-89.33451',\n",
       "    'geonameId': 4435276,\n",
       "    'toponymName': 'University of Southern Mississippi McCain Library and Archives',\n",
       "    'countryId': '6252001',\n",
       "    'fcl': 'S',\n",
       "    'population': 0,\n",
       "    'countryCode': 'US',\n",
       "    'name': 'University of Southern Mississippi McCain Library and Archives',\n",
       "    'fclName': 'spot, building, farm',\n",
       "    'adminCodes1': {'ISO3166_2': 'MS'},\n",
       "    'countryName': 'United States',\n",
       "    'fcodeName': 'library',\n",
       "    'adminName1': 'Mississippi',\n",
       "    'lat': '31.32623',\n",
       "    'fcode': 'LIBR'},\n",
       "   'state': 'Mississippi',\n",
       "   'state_code': 'MS',\n",
       "   'status': 'OK'},\n",
       "  {'address': 'University Library - Freie Universität Berlin',\n",
       "   'class_description': 'spot, building, farm',\n",
       "   'code': 'LIBR',\n",
       "   'country': 'Germany',\n",
       "   'country_code': 'DE',\n",
       "   'description': 'library',\n",
       "   'feature_class': 'S',\n",
       "   'geonames_id': 8623763,\n",
       "   'lat': '52.44812',\n",
       "   'lng': '13.27782',\n",
       "   'ok': True,\n",
       "   'raw': {'adminCode1': '16',\n",
       "    'lng': '13.27782',\n",
       "    'geonameId': 8623763,\n",
       "    'toponymName': 'University Library - Freie Universität Berlin',\n",
       "    'countryId': '2921044',\n",
       "    'fcl': 'S',\n",
       "    'population': 0,\n",
       "    'countryCode': 'DE',\n",
       "    'name': 'University Library - Freie Universität Berlin',\n",
       "    'fclName': 'spot, building, farm',\n",
       "    'adminCodes1': {'ISO3166_2': 'BE'},\n",
       "    'countryName': 'Germany',\n",
       "    'fcodeName': 'library',\n",
       "    'adminName1': 'Berlin',\n",
       "    'lat': '52.44812',\n",
       "    'fcode': 'LIBR'},\n",
       "   'state': 'Berlin',\n",
       "   'state_code': '16',\n",
       "   'status': 'OK'},\n",
       "  {'address': 'Maharishi University of Management Library',\n",
       "   'class_description': 'spot, building, farm',\n",
       "   'code': 'LIBR',\n",
       "   'country': 'United States',\n",
       "   'country_code': 'US',\n",
       "   'description': 'library',\n",
       "   'feature_class': 'S',\n",
       "   'geonames_id': 4865890,\n",
       "   'lat': '41.0178',\n",
       "   'lng': '-91.96934',\n",
       "   'ok': True,\n",
       "   'raw': {'adminCode1': 'IA',\n",
       "    'lng': '-91.96934',\n",
       "    'geonameId': 4865890,\n",
       "    'toponymName': 'Maharishi University of Management Library',\n",
       "    'countryId': '6252001',\n",
       "    'fcl': 'S',\n",
       "    'population': 0,\n",
       "    'countryCode': 'US',\n",
       "    'name': 'Maharishi University of Management Library',\n",
       "    'fclName': 'spot, building, farm',\n",
       "    'adminCodes1': {'ISO3166_2': 'IA'},\n",
       "    'countryName': 'United States',\n",
       "    'fcodeName': 'library',\n",
       "    'adminName1': 'Iowa',\n",
       "    'lat': '41.0178',\n",
       "    'fcode': 'LIBR'},\n",
       "   'state': 'Iowa',\n",
       "   'state_code': 'IA',\n",
       "   'status': 'OK'},\n",
       "  {'address': 'Mannheim University Library',\n",
       "   'class_description': 'spot, building, farm',\n",
       "   'code': 'LIBR',\n",
       "   'country': 'Germany',\n",
       "   'country_code': 'DE',\n",
       "   'description': 'library',\n",
       "   'feature_class': 'S',\n",
       "   'geonames_id': 11001942,\n",
       "   'lat': '49.48545',\n",
       "   'lng': '8.46123',\n",
       "   'ok': True,\n",
       "   'raw': {'adminCode1': '01',\n",
       "    'lng': '8.46123',\n",
       "    'geonameId': 11001942,\n",
       "    'toponymName': 'Mannheim University Library',\n",
       "    'countryId': '2921044',\n",
       "    'fcl': 'S',\n",
       "    'population': 0,\n",
       "    'countryCode': 'DE',\n",
       "    'name': 'Mannheim University Library',\n",
       "    'fclName': 'spot, building, farm',\n",
       "    'adminCodes1': {'ISO3166_2': 'BW'},\n",
       "    'countryName': 'Germany',\n",
       "    'fcodeName': 'library',\n",
       "    'adminName1': 'Baden-Württemberg',\n",
       "    'lat': '49.48545',\n",
       "    'fcode': 'LIBR'},\n",
       "   'state': 'Baden-Württemberg',\n",
       "   'state_code': '01',\n",
       "   'status': 'OK'}],\n",
       " [{'address': 'Library Lake',\n",
       "   'class_description': 'stream, lake, ...',\n",
       "   'code': 'LK',\n",
       "   'country': 'United States',\n",
       "   'country_code': 'US',\n",
       "   'description': 'lake',\n",
       "   'feature_class': 'H',\n",
       "   'geonames_id': 5259908,\n",
       "   'lat': '45.53366',\n",
       "   'lng': '-92.02451',\n",
       "   'ok': True,\n",
       "   'raw': {'adminCode1': 'WI',\n",
       "    'lng': '-92.02451',\n",
       "    'geonameId': 5259908,\n",
       "    'toponymName': 'Library Lake',\n",
       "    'countryId': '6252001',\n",
       "    'fcl': 'H',\n",
       "    'population': 0,\n",
       "    'countryCode': 'US',\n",
       "    'name': 'Library Lake',\n",
       "    'fclName': 'stream, lake, ...',\n",
       "    'adminCodes1': {'ISO3166_2': 'WI'},\n",
       "    'countryName': 'United States',\n",
       "    'fcodeName': 'lake',\n",
       "    'adminName1': 'Wisconsin',\n",
       "    'lat': '45.53366',\n",
       "    'fcode': 'LK'},\n",
       "   'state': 'Wisconsin',\n",
       "   'state_code': 'WI',\n",
       "   'status': 'OK'},\n",
       "  {'address': 'Library Park',\n",
       "   'class_description': 'parks,area, ...',\n",
       "   'code': 'PRK',\n",
       "   'country': 'United States',\n",
       "   'country_code': 'US',\n",
       "   'description': 'park',\n",
       "   'feature_class': 'L',\n",
       "   'geonames_id': 5259910,\n",
       "   'lat': '42.5803',\n",
       "   'lng': '-87.81952',\n",
       "   'ok': True,\n",
       "   'raw': {'adminCode1': 'WI',\n",
       "    'lng': '-87.81952',\n",
       "    'geonameId': 5259910,\n",
       "    'toponymName': 'Library Park',\n",
       "    'countryId': '6252001',\n",
       "    'fcl': 'L',\n",
       "    'population': 0,\n",
       "    'countryCode': 'US',\n",
       "    'name': 'Library Park',\n",
       "    'fclName': 'parks,area, ...',\n",
       "    'adminCodes1': {'ISO3166_2': 'WI'},\n",
       "    'countryName': 'United States',\n",
       "    'fcodeName': 'park',\n",
       "    'adminName1': 'Wisconsin',\n",
       "    'lat': '42.5803',\n",
       "    'fcode': 'PRK'},\n",
       "   'state': 'Wisconsin',\n",
       "   'state_code': 'WI',\n",
       "   'status': 'OK'},\n",
       "  {'address': 'Horicon Public Library',\n",
       "   'class_description': 'spot, building, farm',\n",
       "   'code': 'LIBR',\n",
       "   'country': 'United States',\n",
       "   'country_code': 'US',\n",
       "   'description': 'library',\n",
       "   'feature_class': 'S',\n",
       "   'geonames_id': 8498511,\n",
       "   'lat': '43.45194',\n",
       "   'lng': '-88.63083',\n",
       "   'ok': True,\n",
       "   'raw': {'adminCode1': 'WI',\n",
       "    'lng': '-88.63083',\n",
       "    'geonameId': 8498511,\n",
       "    'toponymName': 'Horicon Public Library',\n",
       "    'countryId': '6252001',\n",
       "    'fcl': 'S',\n",
       "    'population': 0,\n",
       "    'countryCode': 'US',\n",
       "    'name': 'Horicon Public Library',\n",
       "    'fclName': 'spot, building, farm',\n",
       "    'adminCodes1': {'ISO3166_2': 'WI'},\n",
       "    'countryName': 'United States',\n",
       "    'fcodeName': 'library',\n",
       "    'adminName1': 'Wisconsin',\n",
       "    'lat': '43.45194',\n",
       "    'fcode': 'LIBR'},\n",
       "   'state': 'Wisconsin',\n",
       "   'state_code': 'WI',\n",
       "   'status': 'OK'},\n",
       "  {'address': 'Marathon County Public Library',\n",
       "   'class_description': 'spot, building, farm',\n",
       "   'code': 'LIBR',\n",
       "   'country': 'United States',\n",
       "   'country_code': 'US',\n",
       "   'description': 'library',\n",
       "   'feature_class': 'S',\n",
       "   'geonames_id': 5261796,\n",
       "   'lat': '44.95997',\n",
       "   'lng': '-89.63068',\n",
       "   'ok': True,\n",
       "   'raw': {'adminCode1': 'WI',\n",
       "    'lng': '-89.63068',\n",
       "    'geonameId': 5261796,\n",
       "    'toponymName': 'Marathon County Public Library',\n",
       "    'countryId': '6252001',\n",
       "    'fcl': 'S',\n",
       "    'population': 0,\n",
       "    'countryCode': 'US',\n",
       "    'name': 'Marathon County Public Library',\n",
       "    'fclName': 'spot, building, farm',\n",
       "    'adminCodes1': {'ISO3166_2': 'WI'},\n",
       "    'countryName': 'United States',\n",
       "    'fcodeName': 'library',\n",
       "    'adminName1': 'Wisconsin',\n",
       "    'lat': '44.95997',\n",
       "    'fcode': 'LIBR'},\n",
       "   'state': 'Wisconsin',\n",
       "   'state_code': 'WI',\n",
       "   'status': 'OK'},\n",
       "  {'address': 'La Crosse Public Library',\n",
       "   'class_description': 'spot, building, farm',\n",
       "   'code': 'LIBR',\n",
       "   'country': 'United States',\n",
       "   'country_code': 'US',\n",
       "   'description': 'library',\n",
       "   'feature_class': 'S',\n",
       "   'geonames_id': 5258968,\n",
       "   'lat': '43.81136',\n",
       "   'lng': '-91.24486',\n",
       "   'ok': True,\n",
       "   'raw': {'adminCode1': 'WI',\n",
       "    'lng': '-91.24486',\n",
       "    'geonameId': 5258968,\n",
       "    'toponymName': 'La Crosse Public Library',\n",
       "    'countryId': '6252001',\n",
       "    'fcl': 'S',\n",
       "    'population': 0,\n",
       "    'countryCode': 'US',\n",
       "    'name': 'La Crosse Public Library',\n",
       "    'fclName': 'spot, building, farm',\n",
       "    'adminCodes1': {'ISO3166_2': 'WI'},\n",
       "    'countryName': 'United States',\n",
       "    'fcodeName': 'library',\n",
       "    'adminName1': 'Wisconsin',\n",
       "    'lat': '43.81136',\n",
       "    'fcode': 'LIBR'},\n",
       "   'state': 'Wisconsin',\n",
       "   'state_code': 'WI',\n",
       "   'status': 'OK'}],\n",
       " [{'address': 'University of Wisconsin - Superior',\n",
       "   'class_description': 'spot, building, farm',\n",
       "   'code': 'SCH',\n",
       "   'country': 'United States',\n",
       "   'country_code': 'US',\n",
       "   'description': 'school',\n",
       "   'feature_class': 'S',\n",
       "   'geonames_id': 5276837,\n",
       "   'lat': '46.71781',\n",
       "   'lng': '-92.08967',\n",
       "   'ok': True,\n",
       "   'raw': {'adminCode1': 'WI',\n",
       "    'lng': '-92.08967',\n",
       "    'geonameId': 5276837,\n",
       "    'toponymName': 'University of Wisconsin - Superior',\n",
       "    'countryId': '6252001',\n",
       "    'fcl': 'S',\n",
       "    'population': 0,\n",
       "    'countryCode': 'US',\n",
       "    'name': 'University of Wisconsin - Superior',\n",
       "    'fclName': 'spot, building, farm',\n",
       "    'adminCodes1': {'ISO3166_2': 'WI'},\n",
       "    'countryName': 'United States',\n",
       "    'fcodeName': 'school',\n",
       "    'adminName1': 'Wisconsin',\n",
       "    'lat': '46.71781',\n",
       "    'fcode': 'SCH'},\n",
       "   'state': 'Wisconsin',\n",
       "   'state_code': 'WI',\n",
       "   'status': 'OK'},\n",
       "  {'address': 'University Park',\n",
       "   'class_description': 'parks,area, ...',\n",
       "   'code': 'PRK',\n",
       "   'country': 'United States',\n",
       "   'country_code': 'US',\n",
       "   'description': 'park',\n",
       "   'feature_class': 'L',\n",
       "   'geonames_id': 5276816,\n",
       "   'lat': '44.81246',\n",
       "   'lng': '-91.49544',\n",
       "   'ok': True,\n",
       "   'raw': {'adminCode1': 'WI',\n",
       "    'lng': '-91.49544',\n",
       "    'geonameId': 5276816,\n",
       "    'toponymName': 'University Park',\n",
       "    'countryId': '6252001',\n",
       "    'fcl': 'L',\n",
       "    'population': 0,\n",
       "    'countryCode': 'US',\n",
       "    'name': 'University Park',\n",
       "    'fclName': 'parks,area, ...',\n",
       "    'adminCodes1': {'ISO3166_2': 'WI'},\n",
       "    'countryName': 'United States',\n",
       "    'fcodeName': 'park',\n",
       "    'adminName1': 'Wisconsin',\n",
       "    'lat': '44.81246',\n",
       "    'fcode': 'PRK'},\n",
       "   'state': 'Wisconsin',\n",
       "   'state_code': 'WI',\n",
       "   'status': 'OK'},\n",
       "  {'address': 'University of Wisconsin - Milwaukee',\n",
       "   'class_description': 'spot, building, farm',\n",
       "   'code': 'SCH',\n",
       "   'country': 'United States',\n",
       "   'country_code': 'US',\n",
       "   'description': 'school',\n",
       "   'feature_class': 'S',\n",
       "   'geonames_id': 5276856,\n",
       "   'lat': '43.07535',\n",
       "   'lng': '-87.88126',\n",
       "   'ok': True,\n",
       "   'raw': {'adminCode1': 'WI',\n",
       "    'lng': '-87.88126',\n",
       "    'geonameId': 5276856,\n",
       "    'toponymName': 'University of Wisconsin - Milwaukee',\n",
       "    'countryId': '6252001',\n",
       "    'fcl': 'S',\n",
       "    'population': 0,\n",
       "    'countryCode': 'US',\n",
       "    'name': 'University of Wisconsin - Milwaukee',\n",
       "    'fclName': 'spot, building, farm',\n",
       "    'adminCodes1': {'ISO3166_2': 'WI'},\n",
       "    'countryName': 'United States',\n",
       "    'fcodeName': 'school',\n",
       "    'adminName1': 'Wisconsin',\n",
       "    'lat': '43.07535',\n",
       "    'fcode': 'SCH'},\n",
       "   'state': 'Wisconsin',\n",
       "   'state_code': 'WI',\n",
       "   'status': 'OK'},\n",
       "  {'address': 'University of Wisconsin (WIS)',\n",
       "   'class_description': 'spot, building, farm',\n",
       "   'code': 'SCH',\n",
       "   'country': 'United States',\n",
       "   'country_code': 'US',\n",
       "   'description': 'school',\n",
       "   'feature_class': 'S',\n",
       "   'geonames_id': 5276822,\n",
       "   'lat': '43.07388',\n",
       "   'lng': '-89.41095',\n",
       "   'ok': True,\n",
       "   'raw': {'adminCode1': 'WI',\n",
       "    'lng': '-89.41095',\n",
       "    'geonameId': 5276822,\n",
       "    'toponymName': 'University of Wisconsin (WIS)',\n",
       "    'countryId': '6252001',\n",
       "    'fcl': 'S',\n",
       "    'population': 0,\n",
       "    'countryCode': 'US',\n",
       "    'name': 'University of Wisconsin (WIS)',\n",
       "    'fclName': 'spot, building, farm',\n",
       "    'adminCodes1': {'ISO3166_2': 'WI'},\n",
       "    'countryName': 'United States',\n",
       "    'fcodeName': 'school',\n",
       "    'adminName1': 'Wisconsin',\n",
       "    'lat': '43.07388',\n",
       "    'fcode': 'SCH'},\n",
       "   'state': 'Wisconsin',\n",
       "   'state_code': 'WI',\n",
       "   'status': 'OK'},\n",
       "  {'address': 'Lawrence University',\n",
       "   'class_description': 'spot, building, farm',\n",
       "   'code': 'SCH',\n",
       "   'country': 'United States',\n",
       "   'country_code': 'US',\n",
       "   'description': 'school',\n",
       "   'feature_class': 'S',\n",
       "   'geonames_id': 5259622,\n",
       "   'lat': '44.26132',\n",
       "   'lng': '-88.39782',\n",
       "   'ok': True,\n",
       "   'raw': {'adminCode1': 'WI',\n",
       "    'lng': '-88.39782',\n",
       "    'geonameId': 5259622,\n",
       "    'toponymName': 'Lawrence University',\n",
       "    'countryId': '6252001',\n",
       "    'fcl': 'S',\n",
       "    'population': 0,\n",
       "    'countryCode': 'US',\n",
       "    'name': 'Lawrence University',\n",
       "    'fclName': 'spot, building, farm',\n",
       "    'adminCodes1': {'ISO3166_2': 'WI'},\n",
       "    'countryName': 'United States',\n",
       "    'fcodeName': 'school',\n",
       "    'adminName1': 'Wisconsin',\n",
       "    'lat': '44.26132',\n",
       "    'fcode': 'SCH'},\n",
       "   'state': 'Wisconsin',\n",
       "   'state_code': 'WI',\n",
       "   'status': 'OK'}],\n",
       " [],\n",
       " [],\n",
       " [],\n",
       " [],\n",
       " [{'address': 'Acrocorinth',\n",
       "   'class_description': 'spot, building, farm',\n",
       "   'code': 'ANS',\n",
       "   'country': 'Greece',\n",
       "   'country_code': 'GR',\n",
       "   'description': 'archaeological/prehistoric site',\n",
       "   'feature_class': 'S',\n",
       "   'geonames_id': 265410,\n",
       "   'lat': '37.89108',\n",
       "   'lng': '22.87043',\n",
       "   'ok': True,\n",
       "   'raw': {'adminCode1': 'ESYE25',\n",
       "    'lng': '22.87043',\n",
       "    'geonameId': 265410,\n",
       "    'toponymName': 'Akrokórinthos',\n",
       "    'countryId': '390903',\n",
       "    'fcl': 'S',\n",
       "    'population': 0,\n",
       "    'countryCode': 'GR',\n",
       "    'name': 'Acrocorinth',\n",
       "    'fclName': 'spot, building, farm',\n",
       "    'adminCodes1': {'ISO3166_2': 'J'},\n",
       "    'countryName': 'Greece',\n",
       "    'fcodeName': 'archaeological/prehistoric site',\n",
       "    'adminName1': 'Peloponnese',\n",
       "    'lat': '37.89108',\n",
       "    'fcode': 'ANS'},\n",
       "   'state': 'Peloponnese',\n",
       "   'state_code': 'ESYE25',\n",
       "   'status': 'OK'}],\n",
       " [],\n",
       " [],\n",
       " [],\n",
       " [],\n",
       " [],\n",
       " [],\n",
       " []]"
      ]
     },
     "execution_count": 106,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "geocoder_results"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 121,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Roman Forum\n"
     ]
    }
   ],
   "source": [
    "results = geocoder.geonames('Roman Forum', maxRows=5, key=USERNAME)\n",
    "print(next(result.address for result in results))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 148,
   "metadata": {},
   "outputs": [],
   "source": [
    "g = geocoder.google('Al-Fayum')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 149,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "None\n"
     ]
    }
   ],
   "source": [
    "print(g.latlng)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 147,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div style=\"width:100%;\"><div style=\"position:relative;width:100%;height:0;padding-bottom:60%;\"><iframe src=\"data:text/html;charset=utf-8;base64,PCFET0NUWVBFIGh0bWw+CjxoZWFkPiAgICAKICAgIDxtZXRhIGh0dHAtZXF1aXY9ImNvbnRlbnQtdHlwZSIgY29udGVudD0idGV4dC9odG1sOyBjaGFyc2V0PVVURi04IiAvPgogICAgPHNjcmlwdD5MX1BSRUZFUl9DQU5WQVMgPSBmYWxzZTsgTF9OT19UT1VDSCA9IGZhbHNlOyBMX0RJU0FCTEVfM0QgPSBmYWxzZTs8L3NjcmlwdD4KICAgIDxzY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ICAKPC9ib2R5Pgo8c2NyaXB0PiAgICAKICAgIAoKICAgICAgICAgICAgCiAgICAgICAgICAgICAgICB2YXIgYm91bmRzID0gbnVsbDsKICAgICAgICAgICAgCgogICAgICAgICAgICB2YXIgbWFwX2VjZjVhMmM0MDEzNTQ3MjI5Y2IzN2YwYzQ0MmQ5OThjID0gTC5tYXAoCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAnbWFwX2VjZjVhMmM0MDEzNTQ3MjI5Y2IzN2YwYzQ0MmQ5OThjJywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHtjZW50ZXI6IFszNy45Nzk0NSwyMy43MTYyMl0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB6b29tOiA4LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWF4Qm91bmRzOiBib3VuZHMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsYXllcnM6IFtdLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd29ybGRDb3B5SnVtcDogZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjcnM6IEwuQ1JTLkVQU0czODU3CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAKICAgICAgICAKICAgIAogICAgICAgICAgICB2YXIgdGlsZV9sYXllcl83Y2IyMGNiM2UzM2Y0MDU3YjE3ZDcxZjFiZmRiNWFhNCA9IEwudGlsZUxheWVyKAogICAgICAgICAgICAgICAgJ2h0dHBzOi8vY2FydG9kYi1iYXNlbWFwcy17c30uZ2xvYmFsLnNzbC5mYXN0bHkubmV0L2xpZ2h0X2FsbC97en0ve3h9L3t5fS5wbmcnLAogICAgICAgICAgICAgICAgewogICJhdHRyaWJ1dGlvbiI6IG51bGwsCiAgImRldGVjdFJldGluYSI6IGZhbHNlLAogICJtYXhab29tIjogMTgsCiAgIm1pblpvb20iOiAxLAogICJub1dyYXAiOiBmYWxzZSwKICAic3ViZG9tYWlucyI6ICJhYmMiCn0KICAgICAgICAgICAgICAgICkuYWRkVG8obWFwX2VjZjVhMmM0MDEzNTQ3MjI5Y2IzN2YwYzQ0MmQ5OThjKTsKICAgICAgICAKICAgIAogICAgICAgICAgICB2YXIgY2lyY2xlX21hcmtlcl9jZWZkNDFiMDJjZTM0NzBmYTY3MDJmY2EwNmZjNjFmYiA9IEwuY2lyY2xlTWFya2VyKAogICAgICAgICAgICAgICAgWzM4LjYwNDM5MjgsMjIuNzE1MjEyNV0sCiAgICAgICAgICAgICAgICB7CiAgImJ1YmJsaW5nTW91c2VFdmVudHMiOiB0cnVlLAogICJjb2xvciI6ICIjMzE4NmNjIiwKICAiZGFzaEFycmF5IjogbnVsbCwKICAiZGFzaE9mZnNldCI6IG51bGwsCiAgImZpbGwiOiB0cnVlLAogICJmaWxsQ29sb3IiOiAiIzMxODZjYyIsCiAgImZpbGxPcGFjaXR5IjogMC41LAogICJmaWxsUnVsZSI6ICJldmVub2RkIiwKICAibGluZUNhcCI6ICJyb3VuZCIsCiAgImxpbmVKb2luIjogInJvdW5kIiwKICAib3BhY2l0eSI6IDEuMCwKICAicmFkaXVzIjogMTEuNSwKICAic3Ryb2tlIjogdHJ1ZSwKICAid2VpZ2h0IjogMwp9CiAgICAgICAgICAgICAgICApLmFkZFRvKG1hcF9lY2Y1YTJjNDAxMzU0NzIyOWNiMzdmMGM0NDJkOTk4Yyk7CiAgICAgICAgICAgIAo8L3NjcmlwdD4=\" style=\"position:absolute;width:100%;height:100%;left:0;top:0;border:none !important;\" allowfullscreen webkitallowfullscreen mozallowfullscreen></iframe></div></div>"
      ],
      "text/plain": [
       "<folium.folium.Map at 0x10c4cc518>"
      ]
     },
     "execution_count": 147,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "coordinates = [g.latlng]\n",
    "\n",
    "# Set up Folium and populate with weighted coordinates\n",
    "\n",
    "basemap = folium.Map(location=[37.97945, 23.71622], zoom_start=8, tiles='cartodbpositron', width=960, height=512)\n",
    "\n",
    "for i, c in enumerate(coordinates):\n",
    "    folium.CircleMarker([c[0], c[1]], radius=most_common_locations[places_list[i]]*.25, color='#3186cc',\n",
    "                    fill=True, fill_opacity=0.5, fill_color='#3186cc').add_to(basemap)\n",
    "\n",
    "basemap"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 157,
   "metadata": {},
   "outputs": [],
   "source": [
    "test = [x for x, y in Counter(pns_list).most_common(10)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 159,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1919 S Wheeling Ave, Tulsa, OK 74104, USA\n",
      "Corinth 201 00, Greece\n",
      "41 Henson Rd, Corinth, MS 38834, USA\n",
      "Corinth 201 00, Greece\n",
      "Corinth 200 07, Greece\n",
      "5600 N Colony Blvd, The Colony, TX 75056, USA\n",
      "3425 Jackson St, Alexandria, LA 71301, USA\n",
      "Via Villa dei Misteri, 2, 80045 Pompei NA, Italy\n",
      "2313 W Main St, Independence, KS 67301, USA\n",
      "305 Broad St, Rome, GA 30161, USA\n",
      "Rome, Metropolitan City of Rome, Italy\n",
      "5350 Government St, Baton Rouge, LA 70806, USA\n",
      "Via della Salara Vecchia, 5/6, 00186 Roma RM, Italy\n",
      "346 15th Ave E, Seattle, WA 98112, USA\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div style=\"width:100%;\"><div style=\"position:relative;width:100%;height:0;padding-bottom:60%;\"><iframe src=\"data:text/html;charset=utf-8;base64,PCFET0NUWVBFIGh0bWw+CjxoZWFkPiAgICAKICAgIDxtZXRhIGh0dHAtZXF1aXY9ImNvbnRlbnQtdHlwZSIgY29udGVudD0idGV4dC9odG1sOyBjaGFyc2V0PVVURi04IiAvPgogICAgPHNjcmlwdD5MX1BSRUZFUl9DQU5WQVMgPSBmYWxzZTsgTF9OT19UT1VDSCA9IGZhbHNlOyBMX0RJU0FCTEVfM0QgPSBmY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TNmZWExMTAiID48L2Rpdj4KICAgICAgICAKPC9ib2R5Pgo8c2NyaXB0PiAgICAKICAgIAoKICAgICAgICAgICAgCiAgICAgICAgICAgICAgICB2YXIgYm91bmRzID0gbnVsbDsKICAgICAgICAgICAgCgogICAgICAgICAgICB2YXIgbWFwXzgyY2QwZTIyNmJmZTQ0OWFhMGI1NGY2MTUzZmVhMTEwID0gTC5tYXAoCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAnbWFwXzgyY2QwZTIyNmJmZTQ0OWFhMGI1NGY2MTUzZmVhMTEwJywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHtjZW50ZXI6IFszNy45Nzk0NSwyMy43MTYyMl0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB6b29tOiA4LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWF4Qm91bmRzOiBib3VuZHMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsYXllcnM6IFtdLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd29ybGRDb3B5SnVtcDogZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjcnM6IEwuQ1JTLkVQU0czODU3CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAKICAgICAgICAKICAgIAogICAgICAgICAgICB2YXIgdGlsZV9sYXllcl9jMDBkOWYxZTdlNzU0YTMxYjNjN2Q0NDEzYTk2ZGU4ZiA9IEwudGlsZUxheWVyKAogICAgICAgICAgICAgICAgJ2h0dHBzOi8vY2FydG9kYi1iYXNlbWFwcy17c30uZ2xvYmFsLnNzbC5mYXN0bHkubmV0L2xpZ2h0X2FsbC97en0ve3h9L3t5fS5wbmcnLAogICAgICAgICAgICAgICAgewogICJhdHRyaWJ1dGlvbiI6IG51bGwsCiAgImRldGVjdFJldGluYSI6IGZhbHNlLAogICJtYXhab29tIjogMTgsCiAgIm1pbl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iMzMTg2Y2MiLAogICJkYXNoQXJyYXkiOiBudWxsLAogICJkYXNoT2Zmc2V0IjogbnVsbCwKICAiZmlsbCI6IHRydWUsCiAgImZpbGxDb2xvciI6ICIjMzE4NmNjIiwKICAiZmlsbE9wYWNpdHkiOiAwLjUsCiAgImZpbGxSdWxlIjogImV2ZW5vZGQiLAogICJsaW5lQ2FwIjogInJvdW5kIiwKICAibGluZUpvaW4iOiAicm91bmQiLAogICJvcGFjaXR5IjogMS4wLAogICJyYWRpdXMiOiAxMCwKICAic3Ryb2tlIjogdHJ1ZSwKICAid2VpZ2h0IjogMwp9CiAgICAgICAgICAgICAgICApLmFkZFRvKG1hcF84MmNkMGUyMjZiZmU0NDlhYTBiNTRmNjE1M2ZlYTExMCk7CiAgICAgICAgICAgIAogICAgCiAgICAgICAgICAgIHZhciBjaXJjbGVfbWFya2VyX2U5N2FjOThhYmEzMDRiYjY5MTdkMmM3ZWVlZTdkMmQyID0gTC5jaXJjbGVNYXJrZXIoCiAgICAgICAgICAgICAgICBbMzQuOTUwMTUxOCwtODguNDc5ODY0N10sCiAgICAgICAgICAgICAgICB7CiAgImJ1YmJsaW5nTW91c2VFdmVudHMiOiB0cnVlLAogICJjb2xvciI6ICIjMzE4NmNjIiwKICAiZGFzaEFycmF5IjogbnVsbCwKICAiZGFzaE9mZnNldCI6IG51bGwsCiAgImZpbGwiOiB0cnVlLAogICJmaWxsQ29sb3IiOiAiIzMxODZjYyIsCiAgImZpbGxPcGFjaXR5IjogMC41LAogICJmaWxsUnVsZSI6ICJldmVub2RkIiwKICAibGluZUNhcCI6ICJyb3VuZCIsCiAgImxpbmVKb2luIjogInJvdW5kIiwKICAib3BhY2l0eSI6IDEuMCwKICAicmFkaXVzIjogMTAsCiAgInN0cm9rZSI6IHRydWUsCiAgIndlaWdodCI6IDMKfQogICAgICAgICAgICAgICAgKS5hZGRUbyhtYXBfODJjZDBlMjI2YmZlNDQ5YWEwYjU0ZjYxNTNmZWExMTApOwogICAgICAgICAgICAKICAgIAogICAgICAgICAgICB2YXIgY2lyY2xlX21hcmtlcl9iN2Y1OWViNTJmNjE0MTI2YTZjZGUxYTgwYzZjMDNlNSA9IEwuY2lyY2xlTWFya2VyKAogICAgICAgICAgICAgICAgWzM3LjkzODYzNjUsMjIuOTMyMjM4M10sCiAgICAgICAgICAgICAgICB7CiAgImJ1YmJsaW5nTW91c2VFdmVudHMiOiB0cnVlLAogICJjb2xvciI6ICIjMzE4NmNjIiwKICAiZGFzaEFycmF5IjogbnVsbCwKICAiZGFzaE9mZnNldCI6IG51bGwsCiAgImZpbGwiOiB0cnVlLAogICJmaWxsQ29sb3IiOiAiIzMxODZjYyIsCiAgImZpbGxPcGFjaXR5IjogMC41LAogICJmaWxsUnVsZSI6ICJldmVub2RkIiwKICAibGluZUNhcCI6ICJyb3VuZCIsCiAgImxpbmVKb2luIjogInJvdW5kIiwKICAib3BhY2l0eSI6IDEuMCwKICAicmFkaXVzIjogMTAsCiAgInN0cm9rZSI6IHRydWUsCiAgIndlaWdodCI6IDMKfQogICAgICAgICAgICAgICAgKS5hZGRUbyhtYXBfODJjZDBlMjI2YmZlNDQ5YWEwYjU0ZjYxNTNmZWExMTApOwogICAgICAgICAgICAKICAgIAogICAgICAgICAgICB2YXIgY2lyY2xlX21hcmtlcl85Y2Q2Mzg1YzcyNGM0ZTRkYTg4M2M5YWFjNzg3ZmU2YyA9IEwuY2lyY2xlTWFya2VyKAogICAgICAgICAgICAgICAgWzM3Ljg5MDk4MywyMi44NzAwM10sCiAgICAgICAgICAgICAgICB7CiAgImJ1YmJsaW5nTW91c2VFdmVudHMiOiB0cnVlLAogICJjb2xvciI6ICIjMzE4NmNjIiwKICAiZGFzaEFycmF5IjogbnVsbCwKICAiZGFzaE9mZnNldCI6IG51bGwsCiAgImZpbGwiOiB0cnVlLAogICJmaWxsQ29sb3IiOiAiIzMxODZjYyIsCiAgImZpbGxPcGFjaXR5IjogMC41LAogICJmaWxsUnVsZSI6ICJldmVub2RkIiwKICA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ogICAgICAgICAgICAgICAgKS5hZGRUbyhtYXBfODJjZDBlMjI2YmZlNDQ5YWEwYjU0ZjYxNTNmZWExMTApOwogICAgICAgICAgICAKICAgIAogICAgICAgICAgICB2YXIgY2lyY2xlX21hcmtlcl9mMGE2NmNhMmM3M2E0NmYyYjBhZjdmNjYwNjBhMWJiNCA9IEwuY2lyY2xlTWFya2VyKAogICAgICAgICAgICAgICAgWzM3LjIyMzkwNDUsLTk1LjczNjI0NTU5OTk5OTk5XSwKICAgICAgICAgICAgICAgIHsKICAiYnViYmxpbmdNb3VzZUV2ZW50cyI6IHRydWUsCiAgImNvbG9yIjogIiMzMTg2Y2MiLAogICJkYXNoQXJyYXkiOiBudWxsLAogICJkYXNoT2Zmc2V0IjogbnVsbCwKICAiZmlsbCI6IHRydWUsCiAgImZpbGxDb2xvciI6ICIjMzE4NmNjIiwKICAiZmlsbE9wYWNpdHkiOiAwLjUsCiAgImZpbGxSdWxlIjogImV2ZW5vZGQiLAogICJsaW5lQ2FwIjogInJvdW5kIiwKICAibGluZUpvaW4iOiAicm91bmQiLAogICJvcGFjaXR5IjogMS4wLAogICJyYWRpdXMiOiAxMCwKICAic3Ryb2tlIjogdHJ1ZSwKICAid2VpZ2h0IjogMwp9CiAgICAgICAgICAgICAgICApLmFkZFRvKG1hcF84MmNkMGUyMjZiZmU0NDlhYTBiNTRmNjE1M2ZlYTExMCk7CiAgICAgICAgICAgIAogICAgCiAgICAgICAgICAgIHZhciBjaXJjbGVfbWFya2VyXzUwM2IyMjA5NDZmZjRmMWI4NGM5OGY2NGJhOTZiZTE5ID0gTC5jaXJjbGVNYXJrZXIoCiAgICAgICAgICAgICAgICBbMzQuMjU0MTY1LC04NS4xNzI5MDRdLAogICAgICAgICAgICAgICAgewogICJidWJibGluZ01vdXNlRXZlbnRzIjogdHJ1ZSwKICAiY29sb3IiOiAiIzMxODZjYyIsCiAgImRhc2hBcnJheSI6IG51bGwsCiAgImRhc2hPZmZzZXQiOiBudWxsLAogICJma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lSm9pbiI6ICJyb3VuZCIsCiAgIm9wYWNpdHkiOiAxLjAsCiAgInJhZGl1cyI6IDEwLAogICJzdHJva2UiOiB0cnVlLAogICJ3ZWlnaHQiOiAzCn0KICAgICAgICAgICAgICAgICkuYWRkVG8obWFwXzgyY2QwZTIyNmJmZTQ0OWFhMGI1NGY2MTUzZmVhMTEwKTsKICAgICAgICAgICAgCiAgICAKICAgICAgICAgICAgdmFyIGNpcmNsZV9tYXJrZXJfMjcxNGY1NTFlY2UyNDFhNDk0YjI0M2MxMGU0NmRkNTUgPSBMLmNpcmNsZU1hcmtlcigKICAgICAgICAgICAgICAgIFs0Ny42MjE4NzYsLTEyMi4zMTIzNF0sCiAgICAgICAgICAgICAgICB7CiAgImJ1YmJsaW5nTW91c2VFdmVudHMiOiB0cnVlLAogICJjb2xvciI6ICIjMzE4NmNjIiwKICAiZGFzaEFycmF5IjogbnVsbCwKICAiZGFzaE9mZnNldCI6IG51bGwsCiAgImZpbGwiOiB0cnVlLAogICJmaWxsQ29sb3IiOiAiIzMxODZjYyIsCiAgImZpbGxPcGFjaXR5IjogMC41LAogICJmaWxsUnVsZSI6ICJldmVub2RkIiwKICAibGluZUNhcCI6ICJyb3VuZCIsCiAgImxpbmVKb2luIjogInJvdW5kIiwKICAib3BhY2l0eSI6IDEuMCwKICAicmFkaXVzIjogMTAsCiAgInN0cm9rZSI6IHRydWUsCiAgIndlaWdodCI6IDMKfQogICAgICAgICAgICAgICAgKS5hZGRUbyhtYXBfODJjZDBlMjI2YmZlNDQ5YWEwYjU0ZjYxNTNmZWExMTApOwogICAgICAgICAgICAKPC9zY3JpcHQ+\" style=\"position:absolute;width:100%;height:100%;left:0;top:0;border:none !important;\" allowfullscreen webkitallowfullscreen mozallowfullscreen></iframe></div></div>"
      ],
      "text/plain": [
       "<folium.folium.Map at 0x10c29ddd8>"
      ]
     },
     "execution_count": 159,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "places = []\n",
    "coordinates = []\n",
    "\n",
    "for item in test:\n",
    "    g = geocoder.google(item)\n",
    "    if g:\n",
    "        places.append(g.address)\n",
    "        print(g.address)\n",
    "        coordinates.append(g.latlng)\n",
    "\n",
    "# Set up Folium and populate with weighted coordinates\n",
    "\n",
    "basemap = folium.Map(location=[37.97945, 23.71622], zoom_start=8, tiles='cartodbpositron', width=960, height=512)\n",
    "\n",
    "for i, c in enumerate(coordinates):\n",
    "    folium.CircleMarker([c[0], c[1]], color='#3186cc',\n",
    "                    fill=True, fill_opacity=0.5, fill_color='#3186cc').add_to(basemap)\n",
    "\n",
    "basemap        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
